require "#{RAILS_ROOT}/app/classes/cat/rules/starting_rule"
require "#{RAILS_ROOT}/app/classes/cat/rules/item_selection_rule"

#* item_selector.rb
#* Copyright (C) 2010  Embian Inc.
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with This program.  If not, see <http://www.gnu.org/licenses/>.
#  
#* Select items for starting/duaring CAT
#* Author: KyoungMo Yang(E-mail : mo@embian.com)
#* Modified: 2010-11-30
#* References: StartingRule, ItemSelectionRule
class ItemSelector
  
  #* For multiple inheritance
  #* Author: KyoungMo Yang(E-mail : mo@embian.com)
  #* Modified: 2010-11-30
  #* References: StartingRule
  module StartingRule2
    include StartingRule
    #To avoid run method duplication
    alias run2 run
  end
  
  include StartingRule2
  include ItemSelectionRule
  
  #* Functionailities
  # * Returns item as CAT starting point
  #* Parameters 
  # * N/A
  #* Return
  # * [cat_item] : CATItem
  #* Note
  # * Override Rule#run
  def get_starting_point
    #based on pre test/user profile
    return select_item if  profile.theta != 0.0
    cat_item = run2
    
    return cat_item
    
  end
  
  #* Functionailities
  # * Returns item that satisfies "Item Selection Rule"
  #* Parameters 
  # * N/A
  #* Return
  # * [cat_item] : Returns an selected CATItem given by rule.
  #* Note
  # * Override Rule#run
  def select_item
    cat_item = run
    
    return cat_item
  end
end